﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Practices.Prism.Events;
using CorpAbreu.Common;
using Microsoft.Practices.Unity;

namespace Abreu.Base.Views
{
    /// <summary>
    /// Interaction logic for ShellView.xaml
    /// </summary>
    public partial class ShellView : Window
    {
        private IEventAggregator _eventAggregator;
        private IUnityContainer _container;

        public ShellView(IEventAggregator eventAggregator, IUnityContainer container)
        {
            InitializeComponent();
            _container = container;

            this._eventAggregator = eventAggregator;
            this._eventAggregator.GetEvent<MenuCommandSelected>().Subscribe(CloseWindow, true);

        }

        private void CloseWindow(string entry)
        {
            if(entry == "Sair")
                this.Close();
            if (entry == "ChangeUser")
            {
                CorpAbreu.Login.Login log = _container.Resolve<CorpAbreu.Login.Login>();
                log.ShowDialog();
            }
            
        }
    }
}
